/**
 * 自定义事件扩展
 */
;layui.define(['jquery', 'layer', 'form', 'table', 'methods'], function (exports) {
    var o = layui.jquery,
        f = layui.form,
        t = layui.table,
        methods = layui.methods,
        ly = layui.layer,
        handle = {
            // +----------------------------------------------------------------------
            // | 自定义顶部按钮方法
            // +----------------------------------------------------------------------
            top: {
                power: function (that, options) {
                    // that 当前触发事件的元素的 jQuery 对象
                    // options 定义按钮的所有参数

                    console.log(that)
                    console.log(options)
                }
            },
            // +----------------------------------------------------------------------
            // | 自定义右侧按钮方法
            // +----------------------------------------------------------------------
            right: {
                login: function (that, data, options) {
                    methods.confirm('确定要登录吗？', () => {
                        methods.fetchPost(options.url, {id: data.id}, (e) => {
                            if (e.code === 1) {
                                parent.layer.open({
                                    type: 2,
                                    area: ['390px', o(window).height() < 800 ? (90 + '%') : (800 + 'px')],
                                    anim: 2,
                                    offset: 'rb',
                                    shade: 0,
                                    title: '<a  href="' + e.data.url + '" target="_blank" >当前登录 《 ' + e.data.code + '》 右键可选择新窗口打开</a>',
                                    content: "" + e.data.url + "",
                                });
                            } else {
                                ly.msg(e.msg);
                            }
                        })
                    });
                }
            }
        };

    exports('handle', handle);
});